//
//  XNImageCollectionViewCell.m
//  XINNingOA
//
//  Created by samuel on 2022/2/15.
//

#import "XNImageCollectionViewCell.h"
#import "SDWebImage.h"
#import "YTKNetworkConfig.h"
#import "YTKNetworkAgent.h"

@interface XNImageCollectionViewCell()


@property (nonatomic, weak) UIImageView *imgView;

@end


@implementation XNImageCollectionViewCell

+ (instancetype) collectionCellWithCollectionView:(UICollectionView *) collectionView WithIndexPath:(NSIndexPath *) indexPath {
    static NSString *cellID = @"XNImageCollectionViewCellID";
    XNImageCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
    return cell;
}


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        UIImageView *image = [[UIImageView alloc] init];
        image.contentMode = UIViewContentModeScaleAspectFit;
        [self.contentView addSubview:image];
        self.imgView = image;
        [image mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self.contentView);
            make.size.mas_equalTo(CGSizeMake(90, 90));
        }];

    }
    
    return self;
}


- (void)setFileModel:(XNFileModel *)fileModel
{
    _fileModel = fileModel;
    NSString *urlStr = [NSString stringWithFormat:@"%@/%@",[YTKNetworkConfig sharedConfig].baseUrl,fileModel.fileUrl];
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:urlStr]];
}

@end
